#include <stdio.h>

// 假设每次展开 4 次迭代
void unroll(double A[], int n)
{
    #pragma GCC unroll 4
    for (int i = 0; i < n; ++i)
    {
        A[i] = 0;
    }
}

void unroll_full(double A[])
{
    for (int i = 0; i < 4; ++i)
    {
        A[i] = 0;
    }
}

int main() {
    double arr[10] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0};
    unroll(arr, 10);
    printf("After unroll function:\n");
    for (int i = 0; i < 10; ++i) {
        printf("arr[%d] = %.2f\n", i, arr[i]);
    }

    for (int i = 0; i < 10; ++i) {
        arr[i] = i + 1.0;
    }

    unroll_full(arr);
    printf("\nAfter unroll_full function:\n");
    for (int i = 0; i < 10; ++i) {
        printf("arr[%d] = %.2f\n", i, arr[i]);
    }

    return 0;
}
    